<template>
    <div class="container">
        <!-- 选项 -->
        <div class="position-relative">
            <ul class="nav nav-tabs">
                <li class="nav-item">
                    <a class="nav-link" :href="'/profile/'+userId">个人信息</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" :href="'/mypost/'+userId">我的帖子</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link active" :href="'/myreply/'+userId">我的回复</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link"  :href="'/mycource/'+userId">我的课程</a>
                </li>
            </ul>
            <a :href="'/profile/'+userId" class="text-muted position-absolute rt-0">返回个人主页&gt;</a>
        </div>
        <!-- 我的回复 -->
        <div class="mt-4">
            <h6><b class="square"></b> 回复的帖子({{ifshow ?  content.total : 0}})</h6>
            <ul class="list-unstyled mt-4 pl-3 pr-3">
                <li class="border-bottom pb-3 mt-4" v-for="(item,i) in (ifshow ? content.list : [])">
                    <div class="font-size-16 text-info">
                        <a :href="'/discussdetail/'+item.discussPost.id" class="text-info">
                          {{item.discussPost.title}}
                        </a>
                    </div>
                    <div class="mt-1 font-size-14">
                      {{item.comment.content}}
                    </div>
                    <div class="text-right font-size-12 text-muted">
                        回复于 <b>{{item.comment.createTime | datatime}}</b>
                    </div>
                </li>																																															
            </ul>
            <!-- 分页 -->
            <pagination ref="pagination" v-bind:list="getlist" v-bind:itemCount="8"></pagination>	
        </div>				
    </div>
</template>
<script>
import Pagination from "@/components/pagination";
export default {
    name:'myreply',
    data(){
        return{
            content:null,
            userId:"", //用户id
            ifshow:false,
        }
    },
    components: {Pagination},
    watch:{
        content(){
            this.setIfshow();
        }
    },
    mounted(){
        this.getlist(1);
    },
    created(){
      this.userId = this.$route.params.userId;
      this.setIfshow()
    },
    methods:{
        //获取数据
        getlist(page){
            // let _this = this;
            this.$ajax.post(process.env.VUE_APP_SERVER + '/business/web/member/myreply/'+this.userId, {
                page: page,
                size: this.$refs.pagination.size,
            }).then((response)=>{
                console.log("查询帖子详情结果：", response);
                this.content = response.data.content;
                this.$refs.pagination.render(page, response.data.content.pageDto.total);

            })
        },
        //判断对象是有值
        setIfshow(){
            if(this.content != null){
                this.ifshow = true;
            }else{
                this.ifshow = false;
            }
        },
    }
}
</script>

<style lang="scss" scoped>
    @import '@/assets/style/css/global.scss';
</style>